package com.ruoyi.common.service.business.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.pagination.Paging;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.common.core.pagination.PageInfo;
import com.ruoyi.common.param.UserAddressParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.mapper.business.UserAddressMapper;
import com.ruoyi.common.domain.business.UserAddress;
import com.ruoyi.common.service.business.UserAddressService;

/**
 * 收货地址Service业务层处理
 *
 * @author Song
 * @date 2024-10-29
 */
@Service
public class UserAddressServiceImpl extends ServiceImpl<UserAddressMapper, UserAddress> implements UserAddressService {

    @Autowired
    private UserAddressMapper userAddressMapper;

    /**
     * 查询收货地址列表
     *
     * @param userAddress 收货地址
     * @return 收货地址
     */
    public Paging<UserAddress> pageUserAddress(UserAddressParam userAddress) {
        LambdaQueryWrapper<UserAddress> wrapper = new LambdaQueryWrapper<UserAddress>();
        Page<UserAddress> page = new PageInfo<>(userAddress);

        IPage<UserAddress> iPage = this.page(page, wrapper);
        // 最终返回分页对象
//        IPage<UserAddressVo> resultPage = iPage.convert(item -> {
//            UserAddressVo vo = new UserAddressVo();
//            BeanUtil.copyProperties(item, vo);
//            return vo;
//        });
        return new Paging(iPage);
    }
}



